package com.kuaimacode.kframework.admin.services.score;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;

import com.github.pagehelper.PageInfo;
import com.kuaimacode.kframework.mybatis.mapper.score.SysAdminScoreManagentmentMapper;
import com.kuaimacode.kframework.mybatis.models.score.AdminScoreManagentment;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * @author Administrator
 * @date 2019/04/08
 */
@Service
public class  AdminScoreManagentmentService extends ServiceImpl<SysAdminScoreManagentmentMapper, AdminScoreManagentment> {

    	/**
    	 *  分页查找所有的数据
    	 * @param pageNum 当前页码，从1开始
    	 * @param pageSize  一页显示多少行
    	 * @return
    	 */
    	public PageInfo<AdminScoreManagentment> findAll(int pageNum, int pageSize) {
    		PageHelper.startPage(pageNum, pageSize);
    		List<AdminScoreManagentment> datas = baseMapper.selectList(null);
    		return new PageInfo<AdminScoreManagentment>(datas);
    	}

	public AdminScoreManagentment findOne() {
		QueryWrapper<AdminScoreManagentment> queryWrapper = new QueryWrapper<>();
		queryWrapper.eq("status","1");
		List<AdminScoreManagentment> datas = baseMapper.selectList(queryWrapper);
		if (CollectionUtils.isNotEmpty(datas)) {
			return datas.get(0);
		}
		return new AdminScoreManagentment();
	}
}

